<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>create a new DateTime object</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.date-create-immutable.html">« date_create_immutable</a></li>
      <li style="float: right;"><a href="function.date-date-set.html">date_date_set »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.datetime.html">Date/Time 函数</a></li>
    <li>create a new DateTime object</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.date-create" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">date_create</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">date_create</span> &mdash; <span class="dc-title">create a new <span class="classname"><a href="class.datetime.html" class="classname">DateTime</a></span> object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.date-create-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>date_create</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$datetime</code><span class="initializer"> = &quot;now&quot;</span></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type"><a href="class.datetimezone.html" class="type DateTimeZone">DateTimeZone</a></span><span class="type"></span></span> <code class="parameter">$timezone</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type"><a href="class.datetime.html" class="type DateTime">DateTime</a></span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   This is the procedural version of
   <span class="methodname"><a href="datetime.construct.html" class="methodname">DateTime::__construct()</a></span>.
  </p>
  <p class="para">
   Unlike the <span class="classname"><a href="class.datetime.html" class="classname">DateTime</a></span> constructor, it will return
   <strong><code>false</code></strong> instead of an exception if the passed in
   <code class="parameter">datetime</code> string is invalid.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.date-create-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   See <a href="datetimeimmutable.construct.html" class="link">DateTimeImmutable::__construct</a>.
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.date-create-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a new DateTime instance.
   过程化风格在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.date-create-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="datetimeimmutable.construct.html" class="methodname" rel="rdfs-seeAlso">DateTimeImmutable::__construct()</a> - Returns new DateTimeImmutable object</span></li>
   <li class="member"><span class="methodname"><a href="datetimeimmutable.createfromformat.html" class="methodname" rel="rdfs-seeAlso">DateTimeImmutable::createFromFormat()</a> - Parses a time string according to a specified format</span></li>
   <li class="member"><span class="methodname"><a href="datetime.construct.html" class="methodname" rel="rdfs-seeAlso">DateTime::__construct()</a> - 返回新的 DateTime 对象</span></li>
  </ul>
 </div>


</div></div></div></body></html>